package org.foreningsgatan.genetics.racers;


public class Force {
	protected double angle;
	protected double strength;
	
	public Force(double angle, double strength) {
		this.angle = CommonMath.wrap(angle, -Math.PI, Math.PI);
		this.strength = strength;
	}
	
	public static Force sum(Force f1, Force f2) {
		double angle = (f1.angle + f2.angle) / 2;
		double strength = 
			f1.strength * Math.cos(f1.angle - angle) + 
			f2.strength * Math.cos(f2.angle - angle);
		
		return new Force(angle, strength);
	}
	
	public static Force project(Force f1, Force f2) {
		return new Force(f2.angle, f1.strength * Math.cos(f2.angle - f1.angle));
	}
	
	public double getAngle() {
		return angle;
	}

	public double getStrength() {
		return strength;
	}
}
